package com.surfacing.rcp.client.editors;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;

import com.surfacing.rcp.model.entity.Nfs;

public class NfsEditorInput implements IEditorInput {
	// properties
	private Nfs nfs;
	private boolean isNew;

	/**
	 * Default class constructor for the staff member editor.
	 * 
	 * @param nfs
	 *            the nfs to edit
	 * @param login
	 *            the login information accociated with the staff member
	 * @param isNew
	 *            a flag to determine whether the member is new
	 */
	public NfsEditorInput(Nfs nfs, boolean isNew) {
		this.nfs = nfs;
		this.isNew = isNew;
	}

	@Override
	public boolean exists() {
		return false;
	}

	@Override
	public ImageDescriptor getImageDescriptor() {
		return null;
	}

	@Override
	public String getName() {
		if (isNew)
			return "Neuer Mitarbeiter";
		return nfs.getLastName();
	}

	@Override
	public IPersistableElement getPersistable() {
		return null;
	}

	@Override
	public String getToolTipText() {
		return "Mitarbeiter: " + nfs.getLastName() + " " + nfs.getFirstName();
	}

	@Override
	@SuppressWarnings("unchecked")
	public Object getAdapter(Class arg0) {
		return null;
	}

	@Override
	public boolean equals(Object other) {
		if (other instanceof NfsEditorInput) {
			NfsEditorInput otherEditor = (NfsEditorInput) other;
			return nfs.equals(otherEditor.getNfs());
		}
		return false;
	}

	@Override
	public int hashCode() {
		return nfs.hashCode();
	}

	/**
	 * Returns the staff member
	 * 
	 * @return the staff member
	 */
	public Nfs getNfs() {
		return nfs;
	}

	/**
	 * Returns whether or not the staff member is new.
	 * 
	 * @return true if the staff member is created new
	 */
	public boolean isNew() {
		return isNew;
	}
}
